package com.chinasofti.bufferedio;

import java.io.*;

public class Demo01 {
    public static void main(String[] args) throws IOException {
        //字节缓冲输出流
        BufferedOutputStream bos =
                new BufferedOutputStream(new FileOutputStream("java419\\bos.txt") );
        //写数据
        bos.write("hello\r\n".getBytes());
        bos.write("world\r\n".getBytes());
        bos.close();
        //字节缓冲输入流
        BufferedInputStream bis =
                new BufferedInputStream(new FileInputStream("java419\\bos.txt"));
//        int by;
//        while((by = bis.read()) != -1){
//            System.out.print((char)by);
//        }
        byte[] bys = new byte[1024];
        int len;
        while( (len = bis.read(bys)) != -1){
            System.out.print(new String(bys,0,len));
        }
        bis.close();

    }
}